﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace DatabaseComponent
{
    public class FoldersHier : IHierarchyData
    {

        public FoldersHier(Folders objFoldersIn):base()
        {
            objFolders = objFoldersIn;

        }


        Folders _objFolders = new Folders();

        public Folders objFolders
        {
            get { return _objFolders; }
            set { _objFolders = value; }
        }



        public string FolderNameEN
        {
            get
            {
                return _objFolders.FolderNameEN;
            }
        }


        public string FolderNameAR
        {
            get
            {
                return _objFolders.FolderNameAR;
            }
        }

        public long ID
        {
            get
            {
                return _objFolders.ID;
            }
        }


        public string FolderImageUrlSmall
        {
            get
            {
                return _objFolders.FolderImageUrlSmall;
            }
        }


       

        


        // Summary:
        //     Indicates whether the hierarchical data node that the System.Web.UI.IHierarchyData
        //     object represents has any child nodes.
        //
        // Returns:
        //     true if the current node has child nodes; otherwise, false.
        public bool HasChildren {

            get
            {
                return (objFolders.lstChild.Count > 0);
            }
        
        
        }
        //
        // Summary:
        //     Gets the hierarchical data node that the System.Web.UI.IHierarchyData object
        //     represents.
        //
        // Returns:
        //     An System.Object hierarchical data node object.
        public object Item {


            get
            {
                return objFolders;
            }
            
            
            
            }
        //
        // Summary:
        //     Gets the hierarchical path of the node.
        //
        // Returns:
        //     A System.String that identifies the hierarchical path relative to the current
        //     node.
        public string Path {
            get
            {
               return objFolders.PathEN;
            }
            
            
             }
        //
        // Summary:
        //     Gets the name of the type of System.Object contained in the System.Web.UI.IHierarchyData.Item
        //     property.
        //
        // Returns:
        //     The name of the type of object that the System.Web.UI.IHierarchyData object
        //     represents.
        public string Type {


            get
            {
                return "DatabaseComponent.Folders";
            }
            
            
            }

        // Summary:
        //     Gets an enumeration object that represents all the child nodes of the current
        //     hierarchical node.
        //
        // Returns:
        //     An System.Web.UI.IHierarchicalEnumerable collection of child nodes of the
        //     current hierarchical node.
        public IHierarchicalEnumerable GetChildren()
        {
            if (this._objFolders.ID != -1)
                return new FoldersHierList(this._objFolders.lstChild);
            else
                return new FoldersHierList(new List<Folders>());

        }


        //
        // Summary:
        //     Gets an System.Web.UI.IHierarchyData object that represents the parent node
        //     of the current hierarchical node.
        //
        // Returns:
        //     An System.Web.UI.IHierarchyData object that represents the parent node of
        //     the current hierarchical node.
        public IHierarchyData GetParent()
        {

            if (objFolders.ParentID != -1)
            {
                FoldersHier fh = new FoldersHier(objFolders.objParent);
                
                return fh;

            }
            else
            {
                return null;
            }
            
        }
    }
}
